package cn.study.zgm.nettyall.channel;

import java.nio.ByteBuffer;

/**
 * packageName cn.study.zgm.nettyall.channel
 *
 * @author 你的名字
 * @version JDK 8
 * @className TestByteBufferMethod (此处以class为例)
 * @date 2025/2/23
 * @description TODO
 */
public class TestByteBufferReadWrite {
    public static void main(String[] args) {
        final ByteBuffer buffer = ByteBuffer.allocate(10);
        ByteBufferUtil.debugAll(buffer);

        buffer.put((byte) 0x61);
        ByteBufferUtil.debugAll(buffer);
        buffer.put(new byte[]{0x62,0x63,0x64});
        ByteBufferUtil.debugAll(buffer);

        buffer.flip();
        buffer.get(); buffer.get();
        ByteBufferUtil.debugAll(buffer);

        buffer.compact();
        ByteBufferUtil.debugAll(buffer);
//
        buffer.put(new byte[]{0x62,0x63,0x64});
//        buffer.get(); buffer.get(); buffer.get();
//        buffer.compact();
        ByteBufferUtil.debugAll(buffer);
    }
}
